part of '../page.dart';

class _CollectionRepetitionProgressView extends StatelessWidget with ScreenUtilMixin {
  const _CollectionRepetitionProgressView({
    required this.repetitionProgresses,
  });

  final BuiltList<double> repetitionProgresses;

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      color: CoreTheme.of(context).tileColor,
      child: LayoutBuilder(
        builder: (context, constraints) {
          final width = constraints.maxWidth;
          final horizontalPadding = width / 25;
          // final horizontalPadding = width / 20;
          final radius = (width - (repetitionProgresses.length + 1) * horizontalPadding) /
              repetitionProgresses.length /
              2;

          return Padding(
            padding: EdgeInsets.symmetric(
              horizontal: horizontalPadding * 1,
              // vertical: horizontalPadding * 1.1,
              vertical: horizontalPadding,
            ),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: List.generate(repetitionProgresses.length, (index) {
                return AppCircularProgressIndicator(
                  progress: repetitionProgresses[index],
                  radius: radius,
                  thickness: 4 * logWidthScaleFactor,
                  backgroundColor: CoreTheme.of(context).progressIndicatorBackgroundColor,
                  progressColor: CoreTheme.of(context).primaryColor,
                  roundedCap: true,
                  center: Transform.translate(
                    offset: Offset.zero,
                    child: Text(
                      '${index + 1}',
                      style: SingleCollectionPageTheme.of(context).textTheme.repetitionNumber,
                      textScaleFactor: logWidthScaleFactor,
                    ),
                  ),
                );
              }),
            ),
          );
        },
      ),
    );
  }
}
